package com.lmf.annotation;

import com.lmf.annotation.bean.Black;
import com.lmf.annotation.config.MyConfigOfApplicationContextAware;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class IOCTest_BeanApplicationContextAware {
    @Test
    public void test(){
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyConfigOfApplicationContextAware.class);
        String[] beanDefinitionNames = context.getBeanDefinitionNames();
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println(beanDefinitionName);
        }
        System.out.println("--------------------------------");
        Black bean = context.getBean("com.lmf.annotation.bean.Black",Black.class);
        System.out.println(bean);
        //测试当前使用的IOC容器：就是black中的 applicationContext属性
        System.out.println("--------------------------------");
        System.out.println(context);
    }
}
